<template>
  <div class="indexRecommend" :style="outModuleCss">
    <div :style="moduleBgCss" class="module-bg"></div>
    <div class="recommendContent">
      <div class="title" v-if="propsData.params.useTitle == 1">
        <moduleHeader
          :propsData="propsData"
          :moduleName="propsData.params.text"
          @editModuleHeader="editModuleHeader"
        ></moduleHeader>
      </div>
      <div class="recommendList">
        <template v-for="(item, index) in propsData.params.list">
          <div
            class="recommendItem"
            :key="index"
            v-if="index < propsData.params.line * 2"
          >
            <div class="recommendHead">
              <div class="name">
                <div
                  :style="item.title.css"
                  @click.stop="chooseMoudle(item.title)"
                  class="choosed nameTitle"
                >
                  {{ item.title.useTitle == 1 ? item.title.text : "" }}
                  <div class="toChoose"></div>
                </div>
                <div
                  class="countDown choosed"
                  v-if="item.type.style == 1"
                  @click.stop="chooseMoudle(item.type)"
                >
                  <span>00</span>
                  <span>:</span>
                  <span>00</span>
                  <span>:</span>
                  <span>00</span>
                </div>
                <img
                  :src="item.type.picUrl"
                  alt=""
                  class="tip choosed"
                  v-if="item.type.style == 2"
                  @click.stop="chooseMoudle(item.type)"
                />
              </div>
              <span
                class="subName choosed"
                :style="item.subTitle.css"
                v-if="item.subTitle.useTitle == 1"
                @click.stop="chooseMoudle(item.subTitle)"
              >
                {{ item.subTitle.text }}
              </span>
            </div>
            <div
              class="recommendPics choosed"
              @click.stop="chooseMoudle(item.pics)"
            >
              <div
                class="picItem1"
                v-for="(pic, picIndex) in item.pics.urls"
                :key="picIndex"
              >
                <img :src="pic.picUrl" alt="" />
              </div>
              <div
                class="picItem"
                v-for="item in 2 - item.pics.urls.length"
                :key="item"
              ></div>
            </div>
          </div>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import { mixinsModuleCss } from "@/components/DiyNew/diy/mixins/index.js";
import moduleHeader from "@/components/DiyNew/diy/baseControl/moduleHeader/index.vue";

export default {
  name: "indexRecommend",
  props: {
    propsData: {
      type: Object,
      default: {},
    },
  },
  components: {
    moduleHeader,
  },
  mixins: [mixinsModuleCss],
  data() {
    return {};
  },
  methods: {
    chooseMoudle(e) {
      this.$emit("chooseMoudle", e);
    },
    editModuleHeader(e) {
      this.$emit("chooseMoudle", e);
    }
  },
};
</script>

<style lang="scss" scoped>
.indexRecommend {
  position: relative;
  .recommendContent {
    width: 100%;
    padding: 12px 12px 0 12px;
  }
  .module-bg {
    width: 100%;
    height: 100%;
    z-index: -1;
    position: absolute;
    left: 0;
    top: 0;
  }
  .title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .recommendList {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .recommendItem {
      margin-bottom: 12px;
      width: 49%;
      .recommendHead {
        .name {
          display: flex;
          align-items: center;
          .nameTitle {
            min-width: 20px;
            min-height: 23px;
            font-size: 16px;
          }
          .countDown {
            margin-left: 8px;
            display: flex;
            align-items: center;
            font-size: 10px;
            font-weight: 600;
            span:nth-child(2n + 1) {
              width: 15px;
              height: 15px;
              background-color: #fc402f;
              border-radius: 3px;
              display: flex;
              align-items: center;
              justify-content: center;
              color: #fff;
            }
            span:nth-child(2n) {
              color: #fc402f;
              margin: 0 3px;
            }
          }
          .tip {
            min-width: 40px;
            height: 17px;
          }
        }
        .subName {
          display: inline-block;
          font-size: 12px;
        }
      }
      .recommendPics {
        width: 100%;
        height: 80px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .picItem1 {
          width: 49%;
          height: 80px;
          overflow: hidden;
          border-radius: 5px;
          img {
            width: 100%;
            height: 100%;
            object-fit: cover;
          }
        }
        .picItem {
          width: 49%;
          height: 80px;
          background-color: #f2f2f2;
          overflow: hidden;
          border-radius: 5px;
        }
      }
    }
  }
}
.choosed {
  position: relative;
}
.choosed:hover::after {
  cursor: pointer;
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border: 1px solid #1890fc;
}
.choosed:hover::before {
  cursor: pointer;
  content: "\e657";
  font-family: "iconfont";
  position: absolute;
  right: 0;
  top: 0;
  width: 20px;
  height: 20px;
  background-color: #1890fc;
  border-radius: 0 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}
</style>